
<!-- link引入 -->
{include file="common::link"}
{include file="common::pagestyle"}
<body>
<div class="x-body">

    <button class="layui-btn layuiadmin-btn-useradmin" onclick="add()" style="margin: 10px"><i class="layui-icon"></i>添加</button>
    <span class="x-right" style="line-height:40px">共有数据：{$count} 条</span>
    <a href="{:url('waitStatus')}" class="layui-btn" style="float: right;margin: 10px;background-color: red;">待处理</a>
    <a href="{:url('alreadyStatus')}" class="layui-btn" style="float: right;margin: 10px -9px;background-color: darkseagreen;">已处理</a>
  <table class="layui-table">
    <thead>
    <tr>
      <th style="text-align: center;">ID</th>
      <th style="text-align: center;">申请报销人</th>
      <th style="text-align: center;">性别</th>
      <th style="text-align: center;">摘要</th>
      <th style="text-align: center;">报销金额</th>
      <th style="text-align: center;">电子发票</th>
      <th style="text-align: center;">报销单</th>
      <th style="text-align: center;">时间</th>
      <th style="text-align: center;">状态</th>
      <th style="text-align: center;">操作</th>
    </thead>
    <tbody>
    {foreach $res as $v}
    <tr>
      <td style="text-align: center;">{$v.id}</td>
      <td style="text-align: center;">{$v.name}</td>
      <td style="text-align: center;">
        {if condition = "$v.sex eq 1"}男{elseif condition = "$v.sex eq 2"/}女{else /}中性{/if}
      </td>
      <td style="text-align: center;">{$v.content|cut_str=###,10}</td>
      <td style="text-align: center;"><b style="color: deeppink">￥</b><b>{$v.money}</b></td>
<?php $str = 'http://sact.com'; ?>
      <td style="text-align: center;">
          {if condition = "$v.electronic_invoice neq '' "}
<!--          <img src="{$str.$v.electronic_invoice}">-->
<!--          <a href="#" onclick="showBigImage(this)"><img src="{$str.$v.electronic_invoice}"></a>-->
          <img onclick="showBigImage(this)" style="cursor:Pointer" src="{$str.$v.electronic_invoice}">
          {else/}
          暂无图片
          {/if}
      </td>
      <td style="text-align: center;">
          {if condition = "$v.reimbursement neq '' "}
          <img onclick="showBigImage(this)" style="cursor:Pointer"  src="{$str.$v.reimbursement}">
          {else/}
          暂无图片
          {/if}
      </td>
      <td style="text-align: center;">
        {if condition = "$v.update_time neq '' "}
          {$v.update_time|date="Y-m-d H:i:s"}
        {else/}
          {$v.create_time|date="Y-m-d H:i:s"}
        {/if}
      </td>
      <td style="text-align: center;">
        {if condition="$v.status eq 0"}
        <span class="layui-badge">待处理</span>
        {else/}
        <span class="layui-badge layui-bg-green">已处理</span>
        {/if}
      </td>
      <td class="td-manage" style="text-align: center;">
        <button class="layui-btn layui-btn-xs" onclick="edit({$v.id})"><i class="layui-icon"></i></button>
        <button class="layui-btn layui-btn-xs" onclick="del({$v.id})"><i class="layui-icon"></i></button>
      </td>
    </tr>
    {/foreach}
    </tbody>
  </table>
  <div class="page" style="margin:10px">{$res|raw}</div>

</div>

<!-- js引入 -->
{include file="common::script"}

<script>
  layui.use(['layer','table'], function () {
    layer = layui.layer;
    $ = layui.jquery;
    var table = layui.table;

      table.render({
          text: {
              none: '暂无相关数据'
          }
      });

  });

  //点击放大图片
  function showBigImage(e) {
      layer.open({
          type: 1, // 0 信息框默认 1 页面层 2 iframe层 3 加载层 4 tips层
          title: false,
          closeBtn: 0, //隐藏关闭按钮
          shade: [0.7, '#000'],//背景（0.3代表颜色深度）
          shadeClose: true, //点击阴影关闭 遮罩关闭大图
          resize:false,//不可拖拽缩放
          // area: [$(e).width + 'px', $(e).height + 'px'], //宽高 等同于 area: ['auto','auto'],
          area: screen() < 2 ? ['90%', '80%'] : ['1280px', '720px'],
          content: "<img src=" + $(e).attr('src') + " />"
      });
      //判断浏览器大小方法
      function screen() {
          //获取当前窗口的宽度
          var width = $(window).width();
          if (width > 1200) {
              return 3;   //大屏幕
          } else if (width > 992) {
              return 2;   //中屏幕
          } else if (width > 768) {
              return 1;   //小屏幕
          } else {
              return 0;   //超小屏幕
          }
      }
  }

  /*用户-添加*/
  function add() {
    layer.open({
      maxmin: true,
      title: '添加',
      shade: [0.8, '#393D49'],
      area: ['500px', '550px'],
      type: 2,
      content: 'addment',
    });
  }

  /*用户-编辑*/
  function edit(id) {
    layer.open({
      maxmin: true,
      title: '编辑',
      shade: [0.8, '#393D49'],
      area: ['500px', '550px'],
      type: 2,
      content: 'editment?id=' + id,
    });
  }

  /*用户-删除*/
  function del(id) {
    layer.confirm('确认要删除吗？', {
      btn: ['确认', '取消']
    }, function () {
      //发异步删除数据
      $.post('del', { 'id': id }, function (res) {
        if (res.code > 0) {
          layer.alert(res.msg, { icon: 5 });
        } else {
          layer.msg(res.msg);
          setTimeout(function () {
            window.location.reload()
          }, 1000);
        }
      }, 'json');
    });
  }


</script>
</body>
